package com.gemalto.Kryptik;

import com.gemalto.Kryptik.MessageListener;
import java.util.*;

public  final class Messenger {

	private static final Vector listeners = new Vector(5);

	public static void addListener(MessageListener l){
		listeners.add(l);
	}

	public static  void removeListener(MessageListener l){
		MessageListener m;
		Enumeration e = listeners.elements();
		while (e.hasMoreElements()){
			m=(MessageListener)e.nextElement();
			if (m==l) {
				listeners.remove(m);
			}
		}
	}

	public static void error(String text){
		MessageListener m;
		Enumeration e = listeners.elements();
		while (e.hasMoreElements()){
			m=(MessageListener)e.nextElement();
			m.error(text);
		}
	}

	public static void warning(String text){
		MessageListener m;
		Enumeration e = listeners.elements();
		while (e.hasMoreElements()){
			m=(MessageListener)e.nextElement();
			m.warning(text);
		}
	}
}